<?php /* @var $all_debates sfPropelPager */;?>
<?php /* @var $daily_debates sfPropelPager */;?>
<?php use_helper('Date'); ?>
<div class="tabbed">
	<ul class="tabs">
		<li id="tab-debate_byname" class="tab<?php if($view == 'byname') echo ' active'?>">by name</li>
		<li id="tab-debate_byday" class="tab<?php if($view == 'byday') echo ' active'?>">by date</li>
		<li id="tab-debates-respected" class="tab<?php if($view == 'respected') echo ' active'?>">Respected debates</li>		
	</ul>

	<div id="debate_byname" class="content<?php if($view != 'byname') echo ' hide'?>">
		<ul class="debatelist">
		<?php foreach($all_debates->getResults() as $debate):?>
			<li class="debaterow group">
				<img src="<?php echo $debate->getThumbnail()?>" width="100" height="75" />
				<em class="debate debate-<?php echo $debate->getId()?>">"<?php echo $debate->getText(); ?>"</em>
				<?php echo sprintf('%s comments of which %s of your perfect opposites',$debate->getReactionCount(),LypoStatementPeer::getPerfectOppositesReactionCount($user,$debate->getId())) ?>
				<span class="debate debate-<?php echo $debate->getId()?>">Comment now!</span>
			</li>		
		<?php endforeach?>
		</ul>

		<?php if($all_debates->haveToPaginate()): ?>
		<p class="group">
			<?php if($all_debates->getPreviousPage() < $all_debates->getPage()): ?>
				<?php echo link_to('previous seven','@debates?view=byname&userid='.$userid.'&byname_page='.$all_debates->getPreviousPage(),'class=prevlink'); ?>
			<?php endif; ?>
			<?php if($all_debates->getNextPage() > $all_debates->getPage()): ?>
				<?php echo link_to('next seven','@debates?view=byname&userid='.$userid.'&byname_page='.$all_debates->getNextPage(),'class=nextlink'); ?>
			<?php endif; ?>
		</p>
		<?php endif; ?>
	</div>

	<div id="debate_byday" class="content<?php if($view != 'byday') echo ' hide'?>">
		<ul class="debatelist">
		<?php foreach($daily_debates->getResults() as $debate):?>
			<li class="debaterow group">
				<img src="<?php echo $debate->getThumbnail()?>" width="100" height="75" />
				<em class="debate debate-<?php echo $debate->getId()?>">"<?php echo $debate->getText(); ?>"</em>
				<?php echo format_date($debate->getDateUsed(),'P') ?><br/>
				<?php echo sprintf('%s comments of which %s of your perfect opposites',$debate->getReactionCount(),LypoStatementPeer::getPerfectOppositesReactionCount($user,$debate->getId())) ?>
				<span class="debate debate-<?php echo $debate->getId()?>">Comment now!</span>
			</li>		
		<?php endforeach?>
		</ul>

		<?php if($daily_debates->haveToPaginate()): ?>
		<p class="group">
			<?php if($daily_debates->getPreviousPage() < $daily_debates->getPage()): ?>
				<?php echo link_to('previous seven','@debates?view=byday&userid='.$userid.'&byday_page='.$daily_debates->getPreviousPage(),'class=prevlink'); ?>
			<?php endif; ?>
			<?php if($daily_debates->getNextPage() > $daily_debates->getPage()): ?>
				<?php echo link_to('next seven','@debates?view=byday&userid='.$userid.'&byday_page='.$daily_debates->getNextPage(),'class=nextlink'); ?>
			<?php endif; ?>
		</p>
		<?php endif; ?>
	</div>
	
	
	<div id="debates-respected" class="content<?php if($view != 'respected') echo ' hide'?>">
		<ul class="debatelist">
		<?php foreach($respected_debates->getResults() as $debate):?>
			<li class="debaterow group">
				<img src="<?php echo $debate->getThumbnail()?>" width="100" height="75" />
				<em class="debate debate-<?php echo $debate->getId()?>">"<?php echo $debate->getText(); ?>"</em>
				<?php echo sprintf('%s comments of which %s of your perfect opposites',$debate->getReactionCount(),LypoStatementPeer::getPerfectOppositesReactionCount($user,$debate->getId())) ?>
				<span class="debate debate-<?php echo $debate->getId()?>">Comment now!</span>
			</li>		
		<?php endforeach?>
		</ul>

		<?php if($respected_debates->haveToPaginate()): ?>
		<p class="group">
			<?php if($respected_debates->getPreviousPage() < $respected_debates->getPage()): ?>
				<?php echo link_to('previous seven','@debates?view=respected&userid='.$userid.'&respected_page='.$respected_debates->getPreviousPage(),'class=prevlink'); ?>
			<?php endif; ?>
			<?php if($respected_debates->getNextPage() > $respected_debates->getPage()): ?>
				<?php echo link_to('next seven','@debates?view=respected&userid='.$userid.'&respected_page='.$respected_debates->getNextPage(),'class=nextlink'); ?>
			<?php endif; ?>
		</p>
		<?php endif; ?>	
	</div>
</div>